parameters:
  osGroup: ''
  osSubgroup: ''
  archType: ''
  buildConfig: ''
  runtimeFlavor: ''
  helixQueues: ''
  targetRid: ''
  nameSuffix: ''
  platform: ''
  shouldContinueOnError: ''
  rootFolder: ''
  includeRootFolder: ''
  displayName: ''
  artifactName: ''
  archiveExtension: ''
  archiveType: ''
  tarCompression: ''
  hybridGlobalization: False

steps:
# Build Android sample app
  - ${{ if eq(parameters.osGroup, 'android') }}:
    - script: make run MONO_ARCH=arm64 DEPLOY_AND_RUN=false
      workingDirectory: $(Build.SourcesDirectory)/src/mono/sample/Android
      displayName: Build HelloAndroid sample app
    - template: /eng/pipelines/common/upload-artifact-step.yml
      parameters:
        rootFolder: $(Build.SourcesDirectory)/artifacts/bin/AndroidSampleApp/arm64/Release/android-arm64/publish/apk/bin/HelloAndroid.apk
        includeRootFolder: true
        displayName: Android Mono Artifacts
        artifactName: AndroidMonoarm64
        archiveExtension: '.tar.gz'
        archiveType: tar
        tarCompression: gz
    - script: rm -r -f $(Build.SourcesDirectory)/artifacts/bin/AndroidSampleApp
      workingDirectory: $(Build.SourcesDirectory)/artifacts/bin
      displayName: clean bindir

  - ${{ if and(eq(parameters.osGroup, 'ios'), eq(parameters.nameSuffix, 'iOSMono')) }}:
    - script: make build-appbundle TARGET=ios MONO_ARCH=arm64 MONO_CONFIG=Release AOT=True USE_LLVM=False DEPLOY_AND_RUN=false STRIP_DEBUG_SYMBOLS=false HYBRID_GLOBALIZATION=${{ parameters.hybridGlobalization }}
      env:
        DevTeamProvisioning: '-'
      workingDirectory: $(Build.SourcesDirectory)/src/mono/sample/iOS
      displayName: Build HelloiOS AOT sample app LLVM=False STRIP_SYMBOLS=False HYBRID_GLOBALIZATION=${{ parameters.hybridGlobalization }}
    - task: PublishBuildArtifacts@1
      condition: succeededOrFailed()
      displayName: 'Publish binlog'
      inputs:
        pathtoPublish: $(Build.SourcesDirectory)/src/mono/sample/iOS/msbuild.binlog
        artifactName:  ${{ parameters.artifactName }}
    - template: /eng/pipelines/common/upload-artifact-step.yml
      parameters:
        rootFolder: $(Build.SourcesDirectory)/src/mono/sample/iOS/bin/ios-arm64/Bundle/HelloiOS/Release-iphoneos/HelloiOS.app
        includeRootFolder: true
        displayName: iOS Sample App NoLLVM
        artifactName: iOSSampleAppNoLLVMSymbolsHybridGlobalization${{parameters.hybridGlobalization}}
        archiveExtension: '.zip'
        archiveType: zip
    - script: rm -r -f $(Build.SourcesDirectory)/src/mono/sample/iOS/bin
      workingDirectory: $(Build.SourcesDirectory)/src/mono/sample/iOS
      displayName: Clean bindir
    - script: make build-appbundle TARGET=ios MONO_ARCH=arm64 MONO_CONFIG=Release AOT=True USE_LLVM=False DEPLOY_AND_RUN=false STRIP_DEBUG_SYMBOLS=true HYBRID_GLOBALIZATION=${{ parameters.hybridGlobalization }}
      env:
        DevTeamProvisioning: '-'
      workingDirectory: $(Build.SourcesDirectory)/src/mono/sample/iOS
      displayName: Build HelloiOS AOT sample app LLVM=False STRIP_SYMBOLS=True HYBRID_GLOBALIZATION=${{ parameters.hybridGlobalization }}
    - task: PublishBuildArtifacts@1
      condition: succeededOrFailed()
      displayName: 'Publish binlog'
      inputs:
        pathtoPublish: $(Build.SourcesDirectory)/src/mono/sample/iOS/msbuild.binlog
        artifactName:  ${{ parameters.artifactName }}
    - template: /eng/pipelines/common/upload-artifact-step.yml
      parameters:
        rootFolder: $(Build.SourcesDirectory)/src/mono/sample/iOS/bin/ios-arm64/Bundle/HelloiOS/Release-iphoneos/HelloiOS.app
        includeRootFolder: true
        displayName: iOS Sample App NoLLVM NoSymbols
        artifactName: iOSSampleAppNoLLVMNoSymbolsHybridGlobalization${{parameters.hybridGlobalization}}
        archiveExtension: '.zip'
        archiveType: zip
    - script: rm -r -f $(Build.SourcesDirectory)/src/mono/sample/iOS/bin
      workingDirectory: $(Build.SourcesDirectory)/src/mono/sample/iOS
      displayName: Clean bindir
    - script: make build-appbundle TARGET=ios MONO_ARCH=arm64 MONO_CONFIG=Release AOT=True USE_LLVM=True DEPLOY_AND_RUN=false STRIP_DEBUG_SYMBOLS=false HYBRID_GLOBALIZATION=${{ parameters.hybridGlobalization }}
      env:
        DevTeamProvisioning: '-'
      workingDirectory: $(Build.SourcesDirectory)/src/mono/sample/iOS
      displayName: Build HelloiOS AOT sample app LLVM=True STRIP_SYMBOLS=False HYBRID_GLOBALIZATION=${{ parameters.hybridGlobalization }}
    - task: PublishBuildArtifacts@1
      condition: succeededOrFailed()
      displayName: 'Publish binlog'
      inputs:
        pathtoPublish: $(Build.SourcesDirectory)/src/mono/sample/iOS/msbuild.binlog
        artifactName:  ${{ parameters.artifactName }}
    - template: /eng/pipelines/common/upload-artifact-step.yml
      parameters:
        rootFolder: $(Build.SourcesDirectory)/src/mono/sample/iOS/bin/ios-arm64/Bundle/HelloiOS/Release-iphoneos/HelloiOS.app
        includeRootFolder: true
        displayName: iOS Sample App LLVM
        artifactName: iOSSampleAppLLVMSymbolsHybridGlobalization${{parameters.hybridGlobalization}}
        archiveExtension: '.zip'
        archiveType: zip
    - script: rm -r -f $(Build.SourcesDirectory)/src/mono/sample/iOS/bin
      workingDirectory: $(Build.SourcesDirectory)/src/mono/sample/iOS
      displayName: Clean bindir
    - script: make build-appbundle TARGET=ios MONO_ARCH=arm64 MONO_CONFIG=Release AOT=True USE_LLVM=True DEPLOY_AND_RUN=false STRIP_DEBUG_SYMBOLS=true HYBRID_GLOBALIZATION=${{ parameters.hybridGlobalization }}
      env:
        DevTeamProvisioning: '-'
      workingDirectory: $(Build.SourcesDirectory)/src/mono/sample/iOS
      displayName: Build HelloiOS AOT sample app LLVM=True STRIP_SYMBOLS=True HYBRID_GLOBALIZATION=${{ parameters.hybridGlobalization }}
    - task: PublishBuildArtifacts@1
      condition: succeededOrFailed()
      displayName: 'Publish binlog'
      inputs:
        pathtoPublish: $(Build.SourcesDirectory)/src/mono/sample/iOS/msbuild.binlog
        artifactName:  ${{ parameters.artifactName }}
    - template: /eng/pipelines/common/upload-artifact-step.yml
      parameters:
        rootFolder: $(Build.SourcesDirectory)/src/mono/sample/iOS/bin/ios-arm64/Bundle/HelloiOS/Release-iphoneos/HelloiOS.app
        includeRootFolder: true
        displayName: iOS Sample App LLVM NoSymbols
        artifactName: iOSSampleAppLLVMNoSymbolsHybridGlobalization${{parameters.hybridGlobalization}}
        archiveExtension: '.zip'
        archiveType: zip

  - ${{ if and(eq(parameters.osGroup, 'ios'), eq(parameters.nameSuffix, 'iOSNativeAOT')) }}:
    - script: make hello-app TARGET_OS=ios TARGET_ARCH=arm64 BUILD_CONFIG=Release DEPLOY_AND_RUN=false STRIP_DEBUG_SYMBOLS=false HYBRID_GLOBALIZATION=${{ parameters.hybridGlobalization }}
      env:
        DevTeamProvisioning: '-'
      workingDirectory: $(Build.SourcesDirectory)/src/mono/sample/iOS-NativeAOT
      displayName: Build HelloiOS Native AOT sample app STRIP_SYMBOLS=False HYBRID_GLOBALIZATION=${{ parameters.hybridGlobalization }}
    - task: PublishBuildArtifacts@1
      condition: succeededOrFailed()
      displayName: 'Publish binlog'
      inputs:
        pathtoPublish: $(Build.SourcesDirectory)/src/mono/sample/iOS-NativeAOT/msbuild.binlog
        artifactName:  ${{ parameters.artifactName }}
    - template: /eng/pipelines/common/upload-artifact-step.yml
      parameters:
        rootFolder: $(Build.SourcesDirectory)/src/mono/sample/iOS-NativeAOT/bin/ios-arm64/Bundle/HelloiOS/Release-iphoneos/HelloiOS.app
        includeRootFolder: true
        displayName: iOS Sample App Symbols
        artifactName: iOSSampleAppSymbolsHybridGlobalization${{parameters.hybridGlobalization}}
        archiveExtension: '.zip'
        archiveType: zip
    - script: rm -r -f $(Build.SourcesDirectory)/src/mono/sample/iOS-NativeAOT/bin
      workingDirectory: $(Build.SourcesDirectory)/src/mono/sample/iOS-NativeAOT
      displayName: Clean bindir
    - script: make hello-app TARGET_OS=ios TARGET_ARCH=arm64 BUILD_CONFIG=Release DEPLOY_AND_RUN=false STRIP_DEBUG_SYMBOLS=true HYBRID_GLOBALIZATION=${{ parameters.hybridGlobalization }}
      env:
        DevTeamProvisioning: '-'
      workingDirectory: $(Build.SourcesDirectory)/src/mono/sample/iOS-NativeAOT
      displayName: Build HelloiOS Native AOT sample app STRIP_SYMBOLS=True HYBRID_GLOBALIZATION=${{ parameters.hybridGlobalization }}
    - task: PublishBuildArtifacts@1
      condition: succeededOrFailed()
      displayName: 'Publish binlog'
      inputs:
        pathtoPublish: $(Build.SourcesDirectory)/src/mono/sample/iOS-NativeAOT/msbuild.binlog
        artifactName:  ${{ parameters.artifactName }}
    - template: /eng/pipelines/common/upload-artifact-step.yml
      parameters:
        rootFolder: $(Build.SourcesDirectory)/src/mono/sample/iOS-NativeAOT/bin/ios-arm64/Bundle/HelloiOS/Release-iphoneos/HelloiOS.app
        includeRootFolder: true
        displayName: iOS Sample App NoSymbols
        artifactName: iOSSampleAppNoSymbolsHybridGlobalization${{parameters.hybridGlobalization}}
        archiveExtension: '.zip'
        archiveType: zip
